package com.zhang.aloneway_springboot.error;

import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;

@Component
public class ErrorConfig implements ErrorPageRegistrar {
    @Override     //注册错误页面        干这个活的对象
    public void registerErrorPages(ErrorPageRegistry registry) {
        //新new一个ErrorPage 它的状态是NOT_FOUND， 要跳转的页面是index.html
        ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND,"/index.html");
        //把这个404页面注册上
        registry.addErrorPages(errorPage404);
    }
}
